//
//  HonorListTableViewCell.m
//  Cunli
//
//  Created by 湛亚 on 15/8/6.
//  Copyright (c) 2015年 lilubin. All rights reserved.
//

#import "HonorListTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "HonorInfo.h"


#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@interface HonorListTableViewCell (){
    
    UILabel *timeLabel;
    UILabel *detailLabel;
    UILabel *nameLabel;
    float headImgPosition;
}

@end

@implementation HonorListTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style
    reuseIdentifier:(NSString *)reuseIdentifier andHonor:(HonorInfo *)honor
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        UIImageView *bgImgView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH-20, 110)];
        bgImgView.image=[UIImage imageNamed:@"honorbg"];
        [self.contentView addSubview:bgImgView];
        
        if (honor.honorlevel<4) {
            UIImageView *honorImg=[[UIImageView alloc]initWithFrame:CGRectMake(20, 25, 30, 30)];
            honorImg.image=[UIImage imageNamed:[NSString stringWithFormat:@"honorpic%d",honor.honorlevel]];
            [self.contentView addSubview:honorImg];
            headImgPosition=65;
        }else{
            headImgPosition=20;
        }
        
        UIImageView *headImg=[[UIImageView alloc]initWithFrame:CGRectMake(headImgPosition, 20, 40, 40)];
        [headImg setImageWithURL:[NSURL URLWithString:honor.pic] placeholderImage:[UIImage imageNamed:@"default_touxiao.png"]];
        [self.contentView addSubview:headImg];
        
        nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(headImgPosition+50, 20, 100, 20)];
        nameLabel.textColor = [UIColor colorWithRed:18/255.0 green:133/255.0 blue:210/255.0 alpha:1];
        nameLabel.text=honor.honorname;
        //nameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:nameLabel];
        
        detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 70, SCREEN_WIDTH-40, 50)];
        detailLabel.text=honor.introduce;
        detailLabel.numberOfLines=0;
        [self.contentView addSubview:detailLabel];
        
        timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(headImgPosition+50, 45, 100, 15)];
        timeLabel.textColor = [UIColor grayColor];
        timeLabel.text=honor.addtime;
        timeLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:timeLabel];
        
        UIImageView *zanImgPic=[[UIImageView alloc]initWithFrame:CGRectMake( SCREEN_WIDTH-60, 45, 14, 14)];
        zanImgPic.image=[UIImage imageNamed:@"赞2.png"];
        [self.contentView addSubview:zanImgPic];
        
        UILabel *zanLab=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-40, 47, 30, 14)];
        zanLab.textColor = [UIColor colorWithRed:18/255.0 green:133/255.0 blue:210/255.0 alpha:1];
        zanLab.text=honor.look;
        zanLab.font=[UIFont systemFontOfSize:14];
        [self.contentView addSubview:zanLab];
        
        self.zanBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        self.zanBtn.frame=CGRectMake(SCREEN_WIDTH-63,43,55,25);
        [self.contentView addSubview:self.zanBtn];
    }
    return self;
}

- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
